package com.chinasoft;

import com.alibaba.druid.pool.DruidDataSource;
import com.chinasoft.config.SpringConfig;
import com.chinasoft.dao.BookDao;
import com.chinasoft.dao.UserDao;
import com.chinasoft.service.UserService;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class Main {
    public static void main(String[] args) {
//        ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml");
        ApplicationContext ctx = new AnnotationConfigApplicationContext(SpringConfig.class);
        //UserDao userDao = (UserDao)ctx.getBean("userDao");
        //userDao.save();
//        BookDao bookDao = (BookDao)ctx.getBean("bookDao");
//        bookDao.save();
//        DruidDataSource dataSource = (DruidDataSource)ctx.getBean("dataSource");
//        System.out.println("dataSource = " + dataSource);

        UserService userService = (UserService)ctx.getBean("userService");
        userService.save();    }
}